<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 4] The Java Language</TITLE>
<META NAME="author" CONTENT="Pat Niemeyer and Josh Peck">
<META NAME="date" CONTENT="Tue Jul 22 18:50:48 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Exploring Java">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Exploring Java" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch03_05.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 4</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch04_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=chapter><A CLASS="TITLE" NAME="EXJ-CH-4">4. The Java Language</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
Text Encoding<br>
<A HREF="ch04_02.htm">Comments</A><BR>
<A HREF="ch04_03.htm">Types</A><BR>
<A HREF="ch04_04.htm">Statements and Expressions</A><BR>
<A HREF="ch04_05.htm">Exceptions</A><BR>
<A HREF="ch04_06.htm">Arrays</A><BR>

<p>
</DIV>

<P CLASS=para>
In this chapter, we'll introduce the framework of the
Java language and some of its fundamental tools.  I'm not going
to try to provide a full language reference here.  Instead, I'll
lay out the basic structures of Java with special attention to how it
differs from other languages.  For example, we'll take a close
look at arrays in Java, because they are significantly different from
those in some other languages.  We won't, on the other hand,
spend much time explaining basic language constructs like loops and
control structures.  We won't talk much about Java's
object-oriented features here, as that's covered in <A HREF="ch05_01.htm">Chapter 5, <i>Objects in Java</i></A>.

<P CLASS=para>
As always, we'll try to provide meaningful examples to
illustrate how to use Java in everyday programming tasks.

<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="EXJ-CH-4-SECT-1">4.1 Text Encoding</A></h2>

<P CLASS=para>
<A NAME="CH04.ENCODE1"></A><A NAME="CH04.ENCODE2"></A>Java is a language for the Internet. Since the people of the Net speak
and write in many different human languages, Java must be able to
handle a number of languages as well.  One of the ways in which Java supports
international access is through Unicode character encoding. Unicode
uses a 16-bit character encoding; it's a worldwide standard that
supports the scripts (character sets) of most 
languages.[1]

<blockquote class=footnote>
<P CLASS=para>[1] 
For more information about Unicode, see the following
URL: <A HREF="http://www.unicode.org/">http://www.unicode.org/</A>.
Ironically, one listed "obsolete and archaic" scripts not currently supported 
by the Unicode standard is Javanese--a historical language of the people 
of the Island of Java.
</blockquote>
<P CLASS=para>
Java source code can be written using the Unicode character
encoding and stored either in its full form or with
ASCII-encoded Unicode character values. This makes
Java a friendly language for non-English speaking programmers, as
these programmers can use their native alphabet for class, method, and
variable names in Java code.

<P CLASS=para>
The Java <tt CLASS=literal>char</tt> type and <tt CLASS=literal>String</tt>
objects also support Unicode. But if you're concerned about
having to labor with two-byte characters, you can relax. The
<tt CLASS=literal>String</tt> API makes the character
encoding transparent to you. Unicode is also
ASCII-friendly; the first 256 characters are
identical to the first 256 characters in the ISO8859-1 (Latin-1)
encoding and if you stick with these values, there's really no
distinction between the two.

<P CLASS=para>
Most platforms can't display all currently defined
Unicode characters.  As a result, Java programs can be written with
special Unicode escape sequences.  A Unicode character can be
represented with the escape sequence:

<DIV CLASS=screen>
<P>
<PRE>
\u<tt CLASS=replaceable><i>xxxx</i></tt> 
</PRE>
</DIV>

<P CLASS=para>
<tt CLASS=replaceable><i>xxxx</i></tt> is a sequence of one to four hexadecimal
digits. The escape sequence indicates an
ASCII-encoded Unicode character.  This is also the
form Java uses to output a Unicode character in an environment
that doesn't otherwise support them.

<P CLASS=para>
Java stores and manipulates characters and strings internally as Unicode 
values. Java also comes with classes to read and write Unicode-formatted 
character streams, as you'll see in <A HREF="ch08_01.htm">Chapter 8, <i>Input/Output Facilities</i></A>. 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch03_05.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch04_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>The Applet Tag</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Comments</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
